namespace EyeOpen.Logging
{
	using System;

	public static class DependencyResolver
	{
		static DependencyResolver()
		{
			Resolver = new DictionaryDependencyResolver();
		}

		public static IDependencyResolver Resolver { get; set; }

		public static T Resolve<T>()
		{
			CheckResolver();

			return
				Resolver
					.Resolve<T>();
		}

		public static void Register<T>(object obj)
		{
			CheckResolver();

			Resolver
				.Register<T>(obj);
		}

		public static void Register(object obj)
		{
			CheckResolver();

			Resolver
				.Register(obj);
		}

		public static void Remove(object obj)
		{
			CheckResolver();

			Resolver
				.Remove(obj);
		}

		public static void Remove<T>(object obj)
		{
			CheckResolver();

			Resolver
				.Remove<T>(obj);
		}

		private static void CheckResolver()
		{
			if (Resolver == null)
			{
				throw new Exception("The Resolver property is not set.");
			}
		}
	}
}